home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / pmode / 386p_099 / example0.asm < prev    next >
Encoding:
Assembly Source File  |  1994-04-25  |  6.0 KB  |  275 lines

  1. ; 386POWER example program #0.
  2. ; Install a mouse driver, compile, and run.
  3. ; When run, use the left mouse button to draw. Any key exits.
  4.         .386p
  5.  
  6. code32  segment para public use32
  7.         assume cs:code32, ds:code32
  8.  
  9. include 386power.inc
  10. include 386video.inc
  11. include 386file.inc
  12.  
  13. public  _Main
  14.  
  15. CR equ 0dh
  16. LF equ 0ah
  17.  
  18. ; DATA
  19. ex_text         db      'TEST ZERO for 386POWER',CR,LF
  20.                 db      'Testing startup, FILE I/0 & Keyboard',CR,LF
  21.                 db      'PRESS ESC TO EXIT',0
  22. lo_mem          db      'AVAILABLE DOS MEMORY',0
  23. hi_mem          db      'AVAILABLE EXTENDED MEMORY',0
  24. fl_mem          db      'SIZE OF HELLO.TXT FILE',0
  25. tt_mem          db      'TEXT CONTAINED INTO HELLO.TXT:',0
  26. man_text        db      'RUNNING UNDER ',0
  27. systypestr      db      'VCPI','DPMI'
  28. hextuff         db      '0123456789ABCDEF'
  29. d_text          db      8 dup(0)
  30. fname           db      'hello.txt',0
  31. rkbtext         db      'RAW KEYBOARD'
  32. esctext         db      'Press & release ESC to exit '
  33.  
  34. ; CODE
  35.  
  36. PutText:  ; put ECX chars to screen with attr AH
  37.         push edx
  38.         mov  edx,edi
  39. XPutText:        
  40.         lodsb
  41.         cmp al,0
  42.         je CHend
  43.         cmp al,CR
  44.         jne noCR
  45.         mov edi,edx
  46.         jmp nxCH
  47. noCR:   cmp al,LF
  48.         jne noLF
  49.         add edx,160
  50.         add edi,160
  51.         jmp nxCH
  52. noLF:                
  53.         stosw
  54. nxCH:        
  55.         loop XPutText
  56. CHend:        
  57.         pop edx
  58.         ret
  59.  
  60. ;----------------------
  61. d2text: ; edx = dword to convert to hex
  62.         push ebx
  63.         push ecx
  64.         push edi
  65.         
  66.         xor ebx,ebx
  67.         mov edi, offset d_text
  68.         mov ecx, 8
  69.         add edi, 7
  70.         std
  71. txpit:        
  72.         mov ebx,edx
  73.         and ebx,0Fh
  74.         mov al,[ebx+hextuff]
  75.         stosb
  76.         shr edx,4
  77.         loop txpit
  78.         
  79.         pop edi
  80.         pop ecx
  81.         pop ebx
  82.         cld
  83.         ret
  84.         
  85. LargestFree DD 48 dup(0FFFFFFFFh)
  86.  
  87. ;═════════════════════════════════════════════════════════════════════════════
  88. _Main:  mov al,10h
  89.         mov V86ax,0003 ; text mode 80 columns, 16 colors
  90.         int 33h
  91.         
  92.         sti
  93.         @rlp edi,0b8000h     ; get relative pointer to text screen
  94.         mov ecx,(80*25)/2    ; and clear it
  95.         mov eax,00000h
  96.         rep stosd
  97.  
  98.         @rlp edi,0b8000h+(50*2)    ; put type of system
  99.         mov esi,offset man_text
  100.         mov ecx,-1
  101.         mov ah,14
  102.         call PutText
  103.         movzx esi,_386Man
  104.         and esi,1                  ; all the other bits will be 0, but
  105.         lea esi,[esi*4+systypestr] ; what the hell
  106.         mov ecx,4
  107.         mov ah,15
  108.         call PutText
  109.         
  110.         
  111.         mov edx,_HiMemTop
  112.         sub edx,_HiMemBase
  113.         call d2text
  114.         
  115.         @rlp edi,0b8000h
  116.         mov esi,offset d_text
  117.         mov ecx,8
  118.         mov ah,13
  119.         call PutText
  120.         
  121.         @rlp edi,(0b8000h+18)
  122.         mov esi,offset hi_mem
  123.         mov ecx,-1
  124.         mov ah,13
  125.         call PutText
  126.         
  127.         mov edx,_LoMemTop
  128.         sub edx,_LoMemBase
  129.         call d2text
  130.         
  131.         @rlp edi,(0b8000h+160)
  132.         mov esi,offset d_text
  133.         mov ecx,8
  134.         mov ah,12
  135.         call PutText
  136.         
  137.         @rlp edi,(0b8000h+160+18)
  138.         mov esi,offset lo_mem
  139.         mov ecx,-1
  140.         mov ah,12
  141.         call PutText
  142.  
  143.         cmp _386Man,IS_DPMI
  144.         jne naDPMI
  145.         mov ax,0500h
  146.         mov edi,offset LargestFree
  147.         
  148.         int 31h
  149.         rcl edx,1
  150.         and dl,1
  151.         @rlp edi,(0B8000h+(160*3))
  152.         mov ebx,offset LargestFree
  153. glop:
  154.         mov ecx,10
  155. memma:        
  156.         push ecx
  157.         
  158.         push edi
  159.         
  160.         call d2text
  161.         mov esi, offset d_text
  162.         mov ecx,8
  163.         mov ah,7
  164.         call PutText
  165.         
  166.         pop edi 
  167.         
  168.         add edi,160
  169.         mov edx,[ebx]
  170.         add ebx,4
  171.         
  172.         pop ecx
  173.         loop memma
  174.                 
  175. naDPMI:        
  176.         mov esi, offset fname
  177.         call _FLoad
  178.         
  179.         pushad
  180.         mov edx,eax
  181.         call d2text
  182.         
  183.         @rlp edi,(0b8000h+(160*2))
  184.         mov esi,offset d_text
  185.         mov ecx,8
  186.         mov ah,11
  187.         call PutText
  188.         
  189.         @rlp edi,(0b8000h+(160*2)+18)
  190.         mov esi,offset fl_mem
  191.         mov ecx,-1
  192.         mov ah,11
  193.         call PutText
  194.         
  195.         popad
  196.         
  197.         mov ecx,eax
  198.         
  199.         cmp eax,-1
  200.         je noputthis
  201.         mov esi,_HiMemBase
  202.         @rlp edi,(0B8000h+(160*15))
  203.         mov ah,5
  204.         call PutText
  205.         
  206.         @rlp edi,(0b8000h+(160*14))
  207.         mov esi,offset tt_mem
  208.         mov ecx,-1
  209.         mov ah,7
  210.         call PutText
  211.         
  212. noputthis:       
  213.         @rlp edi,(0b8000h+(160*22)+(40*2))
  214.         mov esi,offset ex_text
  215.         mov ecx,-1
  216.         mov ah,10
  217.         call PutText
  218.         
  219.         call _InstallRKB
  220.         
  221.         @rlp edi,(0B8000h+(160*3)+100)
  222.         mov ah,7
  223.         mov ecx,12
  224.         mov esi,offset rkbtext
  225.         call PutText
  226.         @rlp edi,(0B8000h+(160*4)+100)
  227.         mov ah,7
  228.         mov ecx,28
  229.         mov esi,offset esctext
  230.         call PutText
  231.         
  232. kkey:        
  233.         call _WaitKey
  234.         @rlp edi,(0b8000h+(160*5)+120)
  235.         mov esi,offset _RKB
  236.         mov ebx,16
  237. inlup:        
  238.         push edi
  239.         mov ecx,8
  240. glup:        
  241.         lodsb
  242.         mov dx,1720h
  243.         or al,al
  244.         jz zogg
  245.         mov dx,1740h
  246. zogg:   mov [edi],dx
  247.         add edi,2
  248.         loop glup
  249.         pop edi
  250.         add edi,160
  251.         dec ebx
  252.         jne inlup
  253.         mov edi,offset _RKB
  254.         cmp byte ptr [edi+_ESC],02
  255.         je thend
  256.         mov eax,0
  257.         mov ecx,32
  258.         rep stosd
  259.         jmp kkey        
  260. thend:        
  261.         @rlp edi,0b8000h
  262.         mov ecx,2000
  263.         mov al,07
  264. defcolor:        
  265.         inc edi
  266.         stosb
  267.         loop defcolor
  268.         
  269.         jmp _Exit
  270.  
  271.  
  272. code32  ends
  273.         end
  274.  
  275.